package domains;

import config.GlobalConfig;
import controlFlowGraph.*;

public abstract class Analysis {
	
	public void preTransformCFG(CFG cfg) { };
	
	public void postTransformCFG(CFG cfg) { };
	
	public void initialize(CFG cfg) {
		for (CFGNode node : cfg.getAllNodes()) {
			if (GlobalConfig.isForward() && node.getId()==0) {
				node.setAnalysisInfo(getTop());
			} else {
				node.setAnalysisInfo(getBottom());
			}
		}
		if (GlobalConfig.debug) {
			System.out.println("Every node initialized with bottom!");
		}
	}
	
	public abstract AnalysisDomain getBottom();
	
	public abstract AnalysisDomain getTop();
	
	public abstract AnalysisDomain join(AnalysisDomain left, AnalysisDomain right);
	
	public abstract AnalysisDomain meet(AnalysisDomain left, AnalysisDomain right);
	
	public abstract AnalysisDomain widening(AnalysisDomain left, AnalysisDomain right);
	
	public abstract AnalysisDomain narrowing(AnalysisDomain left, AnalysisDomain right);
	
	public AnalysisDomain edgeEffectNOP(CFGEdge edge) {
		return getTop();
	}
	
	public AnalysisDomain edgeEffectPos(CFGEdge edge) {
		return getTop();
	}
	
	public AnalysisDomain edgeEffectNeg(CFGEdge edge) {
		return getTop();
	}
	
	public AnalysisDomain edgeEffectAssign(CFGEdge edge) {
		return getTop();
	}
	
	public AnalysisDomain edgeEffectLoad(CFGEdge edge) {
		return getTop();
	}
	
	public AnalysisDomain edgeEffectStore(CFGEdge edge) {
		return getTop();
	}
	
	public abstract String printNode(CFGNode node);
	
	// others....
	
	// bottom
	// top
	// join
	// meet
	// abstract edge effects
	// widening
	// narrowing
	// -> abstrakt implementieren
	// -> in 3 Unterklassen realisieren
}
